﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace MuMen
{
    [Serializable]
    class DingDanContent
    {
        public DingDanContent()
        {
            //DingDanContentID = "";
            //DingDanID = "";
            //DingDanContentType = "";
            //DingDanContentXingHao = "";
            //DingDanContentCaiZhong = "";
            //DingDanContentLength = 0;
            //DingDanContentWeight = 0;
            //DingDanContentCount = 0;
            BeiZhu = "";
            DingDanContentName = "";
        }

        /// <summary>
        /// 订单内容ID
        /// </summary>
        public string DingDanContentID { get; set; }
        /// <summary>
        /// 订单ID
        /// </summary>
        public string DingDanID { get; set; }
        /// <summary>
        /// 订单内容类型
        /// </summary>
        public string DingDanContentType { get; set; }
        /// <summary>
        /// 型号
        /// </summary>
        public string DingDanContentXingHao { get; set; }
        /// <summary>
        /// 材种
        /// </summary>
        public string DingDanContentCaiZhong { get; set; }
        /// <summary>
        /// 长1
        /// </summary>
        public float DingDanContentLength { get; set; }
        /// <summary>
        /// 宽1
        /// </summary>
        public float DingDanContentWeight { get; set; }
        /// <summary>
        /// 个数1
        /// </summary>
        public int DingDanContentCount { get; set; }

        /// <summary>
        /// 长2
        /// </summary>
        public float DingDanContentLength1{ get; set; }
        
        /// <summary>
        /// 宽2
        /// </summary>
        public float DingDanContentWeight1{ get; set; }
        
        /// <summary>
        /// 个数2
        /// </summary>
        public int DingDanContentCount1{ get; set; }

        /// <summary>
        /// 订单内容名称
        /// </summary>
        public String DingDanContentName { get; set; }

        /// <summary>
        /// 口高度
        /// </summary>
        public int PassHeight { get; set; }

        /// <summary>
        /// 口宽度
        /// </summary>
        public int PassWidth { get; set; }

        /// <summary>
        /// 口厚度
        /// </summary>
        public int PassThickness { get; set; }

        /// <summary>
        /// 套线1长度
        /// </summary>
        public float TaoXianLength { get; set; }

        /// <summary>
        /// 套线1个数
        /// </summary>
        public int TaoXianCount { get; set; }

        /// <summary>
        /// 套线2长度
        /// </summary>
        public float TaoXianLength1 { get; set; }

        /// <summary>
        /// 套线2个数
        /// </summary>
        public int TaoXianCount1 { get; set; }

        /// <summary>
        /// 米数
        /// </summary>
        public float MiShu { get; set; }

        /// <summary>
        /// 钱数
        /// </summary>
        public float Qian { get; set; }

        /// <summary>
        /// 读取订单内容
        /// </summary>
        /// <returns></returns>
        public static List<DingDanContent> GetChooser()
        {

            List<DingDanContent> chooser = new List<DingDanContent>();

            string path = string.Format("{0}\\DingDanContent.bin", System.Windows.Forms.Application.StartupPath);

            if (!File.Exists(path))
            {
                return null;
            }

            //Chooser chooser = new Chooser();
            Encrypt_Decrypt ed = new Encrypt_Decrypt(path);
            chooser = (List<DingDanContent>)ed.DeSerialize();
            return chooser;
        }

        /// <summary>
        /// 写入订单内容
        /// </summary>
        /// <param name="chooser">订单内容</param>
        /// <returns></returns>
        public static bool SetChooser(List<DingDanContent> chooser)
        {
            string path = string.Format("{0}\\DingDanContent.bin", System.Windows.Forms.Application.StartupPath);

            if (!File.Exists(path))
            {
                return false;
            }

            Encrypt_Decrypt ed = new Encrypt_Decrypt(path);
            ed.Serialize(chooser);
            return true;
        }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 套板平方数
        /// </summary>
        public double TaoBanPing { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string BeiZhu { get; set; }
    }

    public class TaoXianContent
    {
        /// <summary>
        /// 套线1长度
        /// </summary>
        public float TaoXianLength { get; set; }

        /// <summary>
        /// 套线1个数
        /// </summary>
        public int TaoXianCount { get; set; }
    }
}
